package com.tuanzi.loan.web.bean.family;

import com.tuanzi.loan.business.service.onekey.CtrlOneKeyOnlineService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.family.CtrlOneKeyOnlineRequest;
import com.tuanzi.loan.vo.response.family.CtrlOneKeyOnlineResponse;
import com.tuanzi.loan.web.configuration.JSFListingSessionBean;
import com.tuanzi.loan.web.lazy.family.CtrlOneKeyOnlineLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.faces.bean.ViewScoped;

/**
 * 控制联登、api上下线
 * @author caiwanlin
 * @create 2018-07-12 11:53
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class CtrlOneKeyOnlineListBean extends JSFListingSessionBean<CtrlOneKeyOnlineRequest,CtrlOneKeyOnlineResponse> {

    @Autowired
    private CtrlOneKeyOnlineService ctrlOneKeyOnlineService;

    @Override
    protected String page() {
        return "/views/family/onekey/ctrl-onekey-online-list.xhtml";
    }

    protected void initLazyDataModel() {
        $ = new CtrlOneKeyOnlineRequest();
        lazyDataModel = new CtrlOneKeyOnlineLazyDataModel($, session, ctrlOneKeyOnlineService);
    }

    public void onReset(){
        initLazyDataModel();
    }

    public String onSee(Long id){
        return redirect("/views/family/onekey/ctrl-onekey-online-info.xhtml?id="+id);
    }

    public String onAdd(){
        return redirect("/views/family/onekey/ctrl-onekey-online-add.xhtml");
    }

    public void online(Long id){
        ctrlOneKeyOnlineService.online(id);
        addSuccessfullyMessage();
    }

    public void offline(Long id){
        ctrlOneKeyOnlineService.offline(id);
        addSuccessfullyMessage();
    }



}
